const mongoose = require("mongoose");
const base_model = require("./base_model");
const md5 = require("../util/md5");

const userSchema = new mongoose.Schema({
  ...base_model,
  username: {
    type: String,
    required: true,
  },
  password: {
    type: String,
    required: true,
    set: (val) => md5(val),
    select: false,
  },
  email: {
    type: String,
    required: true,
  },
  bio: {
    type: String,
    default: null,
  },
  image: {
    type: String,
    default: null,
  },
});

module.exports = userSchema;
